#include "Node.h"
#include "Agent.h"

void Node::LoadObjectSprite(ObjectTypes pObject)
{
	switch (pObject)
	{
	case TreeType1:
		m_xObjectSprite = SpriteManager::GetInstance()->LoadSprite("Images/Tree01.png", 10);
		m_xObjectSprite->setOrigin(26.0f, 50.0f);
		break;

	case TreeType2:
		m_xObjectSprite = SpriteManager::GetInstance()->LoadSprite("Images/Tree02.png", 10);
		m_xObjectSprite->setOrigin(26.0f, 50.0f);
		break;

	case RockType1:
		m_xObjectSprite = SpriteManager::GetInstance()->LoadSprite("Images/Rock01.png", 9);
		m_xObjectSprite->setOrigin(12.5f, 11.5f);
		break;

	case RockType2:
		m_xObjectSprite = SpriteManager::GetInstance()->LoadSprite("Images/Rock02.png", 9);
		m_xObjectSprite->setOrigin(12.5f, 11.5f);
		break;
	}
	m_xObjectSprite->setPosition(m_vPosition);
}

void Node::LoadGroundTile()
{
	int randTile = rand() % 3;

	if (randTile == 2)
	{
		randTile = rand() % 8;
	}
	else
	{
		randTile = 0;
	}

	switch (randTile)
	{
	case 0:
		m_xGroundSprite = SpriteManager::GetInstance()->LoadSprite("Images/GroundTiles/GroundTile01.png", 1);
		break;

	case 1:
		m_xGroundSprite = SpriteManager::GetInstance()->LoadSprite("Images/GroundTiles/GroundTile02.png", 1);
		break;

	case 2:
		m_xGroundSprite = SpriteManager::GetInstance()->LoadSprite("Images/GroundTiles/GroundTile03.png", 1);
		break;

	case 3:
		m_xGroundSprite = SpriteManager::GetInstance()->LoadSprite("Images/GroundTiles/GroundTile04.png", 1);
		break;

	case 4:
		m_xGroundSprite = SpriteManager::GetInstance()->LoadSprite("Images/GroundTiles/GroundTile05.png", 1);
		break;

	case 5:
		m_xGroundSprite = SpriteManager::GetInstance()->LoadSprite("Images/GroundTiles/GroundTile06.png", 1);
		break;

	case 6:
		m_xGroundSprite = SpriteManager::GetInstance()->LoadSprite("Images/GroundTiles/GroundTile07.png", 1);
		break;

	case 7:
		m_xGroundSprite = SpriteManager::GetInstance()->LoadSprite("Images/GroundTiles/GroundTile08.png", 1);
		break;
	}

	m_xGroundSprite->setOrigin(15.0f, 15.0f);
	m_xGroundSprite->setPosition(m_vPosition);
}

void Node::AddAgent(Agent* pAgent)
{
	m_vAgents.push_back(pAgent);
	
}

void Node::RemoveAgent(Agent* pAgent)
{
	for (unsigned int i = 0; i < m_vAgents.size(); i++)
	{
		if (m_vAgents[i] == pAgent)
		{
			m_vAgents.erase(m_vAgents.begin() + i);
		}
	}

}